{%include file="index.header.tpl.php"%}
{%include file="index.left.tpl.php"%}
  <!--主要内容开始-->
  <div class="content-wrapper">
    <section class="content">
      <div class="row">
        <!--树状图-->
        <section class="col-lg-2 connectedSortable" style="padding-right:0;">
         <div class="sidebar" style="background-color:#fff; padding-bottom:0px;">
             <ul class="sidebar-menu" id="chan">
					{%foreach from=$class_lists key=key item=value%}
                    <li class="treeview {%if $key==$class_data.grade_id%}active{%/if%}" >
                      <a href="#">
                        <i class="glyphicon glyphicon-align-left"></i> <span>{%$value.grade_name%}</span> <i class="fa fa-angle-left pull-right"></i>
                      </a>
                          <ul class="treeview-menu" style="background-color:#fff;">
							{%foreach from=$value.class key=k item=v%}
                            <li {%if $v.class_id==$class_data.class_id%}class="active"{%/if%}><a href="index.php?a=score.rangeadd&class_id={%$v.class_id%}"><i class="fa fa-angle-right"></i>  {%$v.class_name%}</a></li>
							{%/foreach%}
                          </ul>
                     </li>
					{%/foreach%}
              </ul>
            </div>
          
        </section>
        <!--树状图结束-->
        <section class="col-lg-10 connectedSortable">
         <div class="box box-default box-solid">
             <form action="" method="post">	
                <div class="box-header with-border">
                    <span class="fa fa-edit (alias)" style="float:left; font-size:18px; padding-top:3px; color:#3c8dbc;" ></span>
                    <p class="box-title">{%$class_data.class_name%}成绩统计分数段设置</p>
                </div>
                <div class="box-body">
                      <div class="form-group">
						  <label class="col-md-1 control-label" style="padding:0; width:110px;">
							   考试分类：
						  </label>
						  <div class="input-group col-md-3 col-sm-12 col-xs-12">
							    <select class="form-control" name="exam_type" id="exams" onchange="exam()">
                                     <option value="">请选择</option>
									{%foreach from=$exam_lists key=key item=value%}
                                     <option value="{%$key%}">{%$value.name%}</option>
									{%/foreach%}
                                </select>
						   </div> 
				      </div>
					  {%foreach from=$exam_lists key=key item=value%}
                      <div class="form-group tea" id="ex{%$key%}" style="display:none">
						  <label class="col-md-1 control-label"  style="padding:0; width:110px;">
							   考试名称：
						  </label>
						  <div class="input-group col-md-10 col-sm-10 col-xs-12">
								{%foreach from=$value.exam key=k item=v%}
							    <label class="choice"><input type="checkbox" name="exam_ids[]" value="{%$k%}"> {%$v%}</label>
								{%/foreach%}
						   </div> 
				      </div>
					  {%/foreach%}

                      <div class="form-group">
						  <label class="col-md-1 control-label"  style="padding:0; width:110px;">
							   选择学科：
						  </label>
						  <div class="input-group col-sm-10 col-xs-12">
						  {%foreach from=$subject_lists key=key item=value%}
							    <label class="choice"><input type="radio" name="subject_id" value="{%$value.subject_id%}"> {%$value.subject_name%}</label>
						  {%/foreach%}
						  {%foreach from=$score_group key=key item=value%}
                                <label class="choice"><input type="radio" name="score_group" value="{$key}"> {%$key%}</label>
						  {%/foreach%}
                                <label class="choice"><input type="radio" name="score_end" value="1"> 总分</label>
						   </div> 
				      </div>
                      <div class="form-group">
						  <label class="col-md-12 control-label"  style="padding:0">
							   分阶设置：<span class="text-info">分阶是用于统计报表中各分数段的人数，注意分阶不要有缺漏或交叉</span>
						  </label>
						  <div class="col-md-5  col-sm-offset-1  col-sm-5 col-xs-12">
							    <table class="table" id="plus" style="width:380px;">
                                       <tr>
                                            <td>操作</td>
                                            <td>分阶</td>
                                            <td>最高分</td>
                                            <td>最低分</td>
                                       </tr>
                                </table>
                                <input type="button" name="xx" onclick="addNewRow();" value="添加分阶" />
                                <input type="button" name="yy" onclick="removeRow();" value="删除分阶" />
						   </div>
                           <div class="col-md-5 col-sm-5 col-xs-12" style="padding-top:40px; margin-left:20px;">
							            <label class="choice">满分：<input type="text" size="10" name="range_full" value=""></label>
                                       <label class="choice"><input type="radio" name="range_fullopen" value="1"> 启用</label>
                                       <label class="choice"><input type="radio" name="range_fullopen" value="0"> 不启用</label>
						   </div>  
				      </div>
                      <div style="clear:both; height:30px;"></div>
                      <div class="form-group">
						  <label class="col-md-12 control-label"  style="padding:0">
							   优良率分数段设置：<span class="text-info">优良率分数段用于统计报表中的各分数层人数及占比</span>
						  </label>
						  <div class="col-md-10 col-sm-offset-1  col-sm-5 col-xs-12">
							    <table class="table">
									{%foreach from=$score_section_ini key=key item=value%}
                                       <tr>
                                            <td style="width:110px;">{%$value%}分数段</td>
                                            <td><input type="text" size="10" name="sectionmin_{%$key%}" value=""></td>
                                            <td>-</td>
                                            <td><input type="text" size="10" name="sectionmax_{%$key%}" value=""></td>
                                            <td style="width:90px;"><label><input type="radio" name="sectionopen_{%$key%}" value="1"> 启用</label></td>
                                            <td><label><input type="radio" name="sectionopen_{%$key%}" value="0"> 不启用</label></td>
                                       </tr>
									{%/foreach%}
                                </table>
						   </div>
				      </div>
                      <div class="form-group">
						  <label class="col-md-12 control-label"  style="padding:0">
							   选择复制学科：<span class="text-info">复制以上学科的分数段给其他学科</span>
						  </label>
						  <div class="col-md-11  col-sm-offset-1  col-sm-11 col-xs-12">
								{%foreach from=$subject_lists key=key item=value%}
                                <label class="choice"><input type="checkbox" name="to_subject[]" value="{%$value.subject_id%}"> {%$value.subject_name%}</label>
								{%/foreach%}
                          </div>
                      </div>
                       <div class="form-group">
						  <label class="col-md-12 control-label"  style="padding:0">
							   选择复制班级：<span class="text-info">将所选班级各科分数段及各类考试信息复制给其他班级，相同学科的直接复制，不相同学科要自行分配。</span>
						  </label>
						  <div class="col-md-11  col-sm-offset-1  col-sm-11 col-xs-12">
                                 <ul id="treeDemo" class="ztree"></ul>
                                   <div style="display:none;">
                                        被勾选时：<input type="checkbox" id="py" class="checkbox first" checked /><span>关联父</span>
                                        <input type="checkbox" id="sy" class="checkbox first" checked /><span>关联子</span><br/>
                                        取消勾选时：<input type="checkbox" id="pn" class="checkbox first" checked /><span>关联父</span>
                                        <input type="checkbox" id="sn" class="checkbox first" checked /><span>关联子</span><br/>
                                    </div>  
                          </div>
                      </div>
     
                    
				</div><!--box-body -->
						<div id="hiddenBox"></div>
                <div class="box-footer text-center">
                    <button type="submit" class="btn btn-primary " onclick="c();">  确 定</button>
                </div>
              </form>
           </div><!--box box-default box-solid-->
         </section>   
        </div><!--row-->
    </section>
 </div>
  <!--主要内容结束-->
{%include file="index.footer.tpl.php"%}
   <script type="text/javascript">

        function exam()
        {
			$(".tea").hide();
            var val = $("#exams").val();
			$("#ex"+val).show();
        }
    </script>
    
    <script language="javascript">
 //窗口表格增加一行
  function addNewRow(){
   var tabObj=document.getElementById("plus");//获取添加数据的表格
   var rowsNum = tabObj.rows.length;  //获取当前行数
   var colsNum=tabObj.rows[rowsNum-1].cells.length;//获取行的列数
   var myNewRow = tabObj.insertRow(rowsNum);//插入新行
   var newTdObj1=myNewRow.insertCell(0);
   newTdObj1.innerHTML="<input type='checkbox' name='chkArr' id='chkArr"+rowsNum+"' style='width:20px' />";
   var newTdObj2=myNewRow.insertCell(1);
   newTdObj2.innerHTML="<input type='text' name='level_name"+rowsNum+"' id='nodecode"+rowsNum+"' style='width:50px' value='分阶"+rowsNum+"'/>";
   var newTdObj3=myNewRow.insertCell(2);
   newTdObj3.innerHTML="<input type='text' name='level_max"+rowsNum+"' id='nodename"+rowsNum+"' style='width:80px' />";
   var newTdObj4=myNewRow.insertCell(3);
   newTdObj4.innerHTML="<input type='text' name='level_min"+rowsNum+"' id='nodeper"+rowsNum+"' style='width:80px' />";
  }
//窗口表格删除一行
  function removeRow(){
   var chkObj=document.getElementsByName("chkArr");
   var tabObj=document.getElementById("plus");
   for(var k=0;k<chkObj.length;k++){
    if(chkObj[k].checked){
     tabObj.deleteRow(k+1);
     k=-1;
    }
   }
  }
</script>
<script type="text/javascript" src="static/js/jquery.ztree.core.js"></script><!--树形-->
<script type="text/javascript" src="static/js/jquery.ztree.excheck.js"></script><!--树形-->
<script type="text/javascript">
		var setting = {
			check: {
				enable: true,	
			},
			data: {
				simpleData: {
					enable: true
				}
			}
		};
		var zNodes =[
		{%foreach from=$class_lists key=key item=value%}
			{ id:"g{%$key%}", pId:0, name:"{%$value.grade_name%}",},
			{%foreach from=$value.class key=k item=v%}
			{ id:"c{%$v.class_id%}", pId:"g{%$key%}", name:"{%$v.class_name%}",},
			{%/foreach%}
		{%/foreach%}
		];
		var code;
		
		function setCheck() {
			var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
			py = $("#py").attr("checked")? "p":"",
			sy = $("#sy").attr("checked")? "s":"",
			pn = $("#pn").attr("checked")? "p":"",
			sn = $("#sn").attr("checked")? "s":"",
			type = { "Y":py + sy, "N":pn + sn};
			zTree.setting.check.chkboxType = type;
			showCode('setting.check.chkboxType = { "Y" : "' + type.Y + '", "N" : "' + type.N + '" };');
		}
		function showCode(str) {
			if (!code) code = $("#code");
			code.empty();
			code.append("<li>"+str+"</li>");
		}
		$(document).ready(function(){
			$.fn.zTree.init($("#treeDemo"), setting, zNodes);
			setCheck();
			$("#py").bind("change", setCheck);
			$("#sy").bind("change", setCheck);
			$("#pn").bind("change", setCheck);
			$("#sn").bind("change", setCheck);
		});
function c()
{
	var delidID = "";
	var zTree = $.fn.zTree.getZTreeObj("treeDemo").getCheckedNodes(true);//获取所有选中状态的节点  
	for (var i = 0; i < zTree.length; i++) {  
		//delidID += zTree[i].id + ",";
		$("#hiddenBox").append('<input type="hidden" name="to_class[]" value="'+zTree[i].id+'">');
	}

} 	
</script>

